<?php

declare(strict_types=1);

namespace App\Request;

use Hyperf\Validation\Request\FormRequest;

class CompanyRegisterRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'name' => 'required|max:120',
            'email' => 'required|email',
            'nick_name' => 'required|max:120',
            'password' => 'required|alpha_dash|max:16',
            'passwords' => 'required|same:password',
            'phone' => 'required|regex:/^1[3456789]\d{9}$/i',
            'code' => 'required',
            'code_key' => 'required'
        ];
    }

    /**
     * 获取验证错误的自定义属性
     */
    public function attributes(): array
    {
        return [
            'name' => '公司名称',
            'nick_name' => '用户名称',
            'email' => '邮箱',
            'password' => '密码',
            'passwords' => '确认密码',
            'phone' => '手机号码',
            'code' => '手机验证码',
            'code_key' => '手机验证码',
        ];
    }

    public function messages(): array
    {
        return [
            'passwords.same' => '确认密码与密码不一致'
        ];
    }
}
